package com.gexiaobao.pigeon.ui.adapter

import androidx.appcompat.widget.AppCompatImageView
import androidx.appcompat.widget.AppCompatTextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.ext.RxTextTool
import com.gexiaobao.pigeon.app.model.bean.OrderGoodBean
import com.gexiaobao.pigeon.app.util.ImageLoaderManager
import com.gexiaobao.pigeon.databinding.ItemOrderGoodsListBinding
import com.makeramen.roundedimageview.RoundedImageView

/**
 * @Author      : hxw
 * @Date        : 2024/12/4 14:03
 * @Describe    :
 */
class AdapterOrderGoods(data: ArrayList<OrderGoodBean>) :
    BaseQuickAdapter<OrderGoodBean, DataBindBaseViewHolder>(R.layout.item_order_goods_list, data) {

    override fun convert(holder: DataBindBaseViewHolder, item: OrderGoodBean) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemOrderGoodsListBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        val ivOrderGoodImage = holder.getView<RoundedImageView>(R.id.ivOrderGoodImage)
        ImageLoaderManager.loadRoundImage(context, item.t7lUrl, ivOrderGoodImage, 6)

        val tvOrderGoodsPrice = holder.getView<AppCompatTextView>(R.id.tvOrderGoodsPrice)
        RxTextTool.getBuilder("￥")
            .append(item.finalPrice.toString()).setAppearance(50).setTextColor(ContextCompat.getColor(context, R.color.color_fe4542))
            .into(tvOrderGoodsPrice)
    }
}